// concatenates arrays
const path = require('path');
const merge = require('webpack-merge');
const cwd = process.cwd();
const config = require('./webpack.base.conf.js');
// 拷贝图片
const CopyWebpackPlugin = require('copy-webpack-plugin');
// 压缩js
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
// 清理./dist文件夹
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = merge(config,{
    plugins: [
        new CleanWebpackPlugin(['dist','build','dist/img'],{
            root: cwd,
            exclude: ['shared.js'],  // 排除
            verbose: true           // 打印
        }),
        new UglifyJSPlugin(),
        // new CopyWebpackPlugin([
        //     {
        //         from: path.join(cwd, 'src/img'),
        //         to: path.join(cwd, 'dist/img')
        //     }
        // ])
    ]
});